package com.yztc.orangeentertainment.ui.main.findfragment.findmain;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yztc.orangeentertainment.R;
import com.yztc.orangeentertainment.base.BaseActivity;
import com.yztc.orangeentertainment.bean.findbean.FindMoreDataBean;
import com.yztc.orangeentertainment.bean.findbean.FindMoreDataListBean;
import com.yztc.orangeentertainment.config.FindUrlConfig;
import com.yztc.orangeentertainment.ui.main.findfragment.findadapter.FindMoreRlvAdapter;
import com.yztc.orangeentertainment.ui.main.findfragment.findui.FindContract;
import com.yztc.orangeentertainment.ui.main.findfragment.findui.FindPresenter;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by My on 2016/10/10.
 */
public class FindMoreActivity extends BaseActivity implements FindContract.View {

    @InjectView(R.id.findmore)
    LinearLayout findmore;
    @InjectView(R.id.findmore_guize)
    TextView findmoreGuize;
    @InjectView(R.id.rank_iv)
    ImageView rankIv;
    @InjectView(R.id.rank_tv)
    TextView rankTv;
    @InjectView(R.id.findmore_check)
    TextView findmoreCheck;
    @InjectView(R.id.findmore_rlv)
    RecyclerView findmoreRlv;
    @InjectView(R.id.findmore_title)
    TextView findmoreTitle;
    @InjectView(R.id.findmore_data)
    TextView findmoreData;
    @InjectView(R.id.findmore_left)
    TextView findmoreLeft;

    public static ImageView findmoreStariv1;
    public static TextView findmoreSatrtv1;
    public static LinearLayout findmoreStar1;
    public static ImageView findmoreStariv2;
    public static TextView findmoreSatrtv2;
    public static LinearLayout findmoreStar2;
    public static ImageView findmoreStariv3;
    public static TextView findmoreSatrtv3;
    public static LinearLayout findmoreStar3;

    public static ImageView moreIv1;
    public static ImageView showIv1;
    public static FrameLayout findmoreIv1;
    public static TextView showTvname1;
    public static TextView showTveng1;
    public static ImageView moreIv2;
    public static ImageView showIv2;
    public static FrameLayout findmoreIv2;
    public static TextView showTvname2;
    public static TextView showTveng2;
    public static ImageView moreIv3;
    public static ImageView showIv3;
    public static FrameLayout findmoreIv3;
    public static TextView showTvname3;
    public static TextView showTveng3;


    private FindContract.Presenter presenter = new FindPresenter(this);

    @Override
    public int getLayoutId() {
        return R.layout.find_more;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
        initView();
    }

    public void initView() {
        //初始化数据
        moreIv1 = (ImageView) findViewById(R.id.more_iv1);
        showIv1 = (ImageView) findViewById(R.id.show_iv1);
        findmoreIv1 = (FrameLayout) findViewById(R.id.findmore_iv1);
        showTvname1 = (TextView) findViewById(R.id.show_tvname1);
        showTveng1 = (TextView) findViewById(R.id.show_tveng1);

        moreIv2 = (ImageView) findViewById(R.id.more_iv2);
        showIv2 = (ImageView) findViewById(R.id.show_iv2);
        findmoreIv2 = (FrameLayout) findViewById(R.id.findmore_iv2);
        showTvname2 = (TextView) findViewById(R.id.show_tvname2);
        showTveng2 = (TextView) findViewById(R.id.show_tveng2);

        moreIv3 = (ImageView) findViewById(R.id.more_iv3);
        showIv3 = (ImageView) findViewById(R.id.show_iv3);
        findmoreIv3 = (FrameLayout) findViewById(R.id.findmore_iv3);
        showTvname3 = (TextView) findViewById(R.id.show_tvname3);
        showTveng3 = (TextView) findViewById(R.id.show_tveng3);

        findmoreStar1 = (LinearLayout) findViewById(R.id.findmore_star1);
        findmoreStariv1 = (ImageView) findViewById(R.id.findmore_stariv1);
        findmoreSatrtv1 = (TextView) findViewById(R.id.findmore_satrtv1);

        findmoreStar2 = (LinearLayout) findViewById(R.id.findmore_star2);
        findmoreStariv2 = (ImageView) findViewById(R.id.findmore_stariv2);
        findmoreSatrtv2 = (TextView) findViewById(R.id.findmore_satrtv2);

        findmoreStar3 = (LinearLayout) findViewById(R.id.findmore_star3);
        findmoreStariv3 = (ImageView) findViewById(R.id.findmore_stariv3);
        findmoreSatrtv3 = (TextView) findViewById(R.id.findmore_satrtv3);

        presenter.getFindMoreDataBeanFromNet(FindUrlConfig.FindPath.MORE_URL, this);
        findmoreTitle.setText("明星排行榜");
        findmoreRlv.setLayoutManager(new LinearLayoutManager(this) {
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        });

        findmore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        findmoreGuize.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(FindMoreActivity.this, FindRuleActivity.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public void getFindMoreDataBeanSucess(FindMoreDataBean findMoreDataBean) {
        //明星排行
        findmoreData.setText(findMoreDataBean.getDate());
        findmoreLeft.setText("距离本期结束还有" + findMoreDataBean.getLeft() + "天");
        List<FindMoreDataListBean> findMoreDataListBeens = findMoreDataBean.getList();
        FindMoreRlvAdapter adapter = new FindMoreRlvAdapter(this, findMoreDataListBeens);
        findmoreRlv.setAdapter(adapter);
    }

    @Override
    public void getFindMoreDataBeanFail(String msg) {

    }
}
